import requests


# 定义一个类
class JCEmpApi(object):
    # 定义 添加员工方法
    @classmethod
    def add_emp(cls, header, req_data):
        resp = requests.post(url="http://116.62.53.189:48080/admin-api/system/user/create",
                             headers=header,
                             json=req_data)
        return resp

    # 定义 查询员工方法
    @classmethod
    def query_emp(cls, emp_id, header):
        resp = requests.get(url="http://116.62.53.189:48080/admin-api/system/user/get?id=" + emp_id,
                            headers=header)
        return resp

    # 定义 修改员工方法
    @classmethod
    def modify_emp(cls, header, req_data):
        resp = requests.put(url="http://116.62.53.189:48080/admin-api/system/user/update",
                            headers=header,
                            json=req_data)
        return resp

    # 定义 删除员工方法
    @classmethod
    def delete_emp(cls, emp_id, header):
        resp = requests.delete(url="http://116.62.53.189:48080/admin-api/system/user/delete?id=" + emp_id,
                               headers=header)
        return resp


if __name__ == '__main__':
    req_header = {"content-type": "application/json", "Authorization": "Bearer 876fa56a7f8f4c9f9f6a49b1afcffab0"}
    json = {"nickname": "测试", "deptId": "", "mobile": "19811111111", "email": "", "username": "ceshi111",
            "password": "123456", "postIds": [], "remark": "", "status": 0, "roleIds": []}
    #   测试新增接口
    # res = JCEmpApi.add_emp(req_header, json)
    # print(res.json())

    #   测试查询接口
    # res = JCEmpApi.query_emp("142", req_header)
    # print("查询结果是:", res.json())

    #   测试修改接口
    # modify_data = {"id": 142, "no": None, "username": "ceshiJXZ", "nickname": "吉秀芝", "remark": "",
    #                "deptId": None, "deptName": None, "postIds": [], "postName": None, "email": "",
    #                "mobile": "19822222222", "sex": 0, "avatar": "", "status": 0, "loginIp": "",
    #                "loginDate": None, "createTime": 1760769481000}
    # res = JCEmpApi.modify_emp(req_header, modify_data)
    # print("修改结果是:", res.json())

    # 测试删除接口
    res = JCEmpApi.delete_emp("142", req_header)
    print("删除结果是:", res.json())
